package org.mrjbee.share.it.easy.client.daemon.mbeans;

import java.lang.management.ManagementFactory;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.StandardMBean;

import org.mrjbee.share.it.easy.client.daemon.command.Command;

public class MBeansManager {

	public void openInterface(Command command) throws MalformedObjectNameException, NullPointerException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
		MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
		ObjectName mxbeanName = new ObjectName("org.mrjbee.shared.clipboard.client.daemon:type=RemoteControl");
		mbs.registerMBean(new StandardMBean(new RemoteControlImpl(command),RemoteControl.class), mxbeanName);
	}
}
